package com.ss.android.article.base.utils;

import android.text.Layout;
import android.text.SpannableStringBuilder;
import android.view.ViewTreeObserver;
import android.widget.TextView;

public final class k implements ViewTreeObserver.OnPreDrawListener {
    private final TextView a;
    private final int b;

    public k(TextView arg2) {
        this.a = arg2;
        this.b = 3;

    }

    public final boolean onPreDraw() {
        boolean v0 = true;
        this.a.getViewTreeObserver().removeOnPreDrawListener(((ViewTreeObserver.OnPreDrawListener)this));
        this.a.setTag(com.ss.android.article.browser.R.id.bz, null);
        Layout v2 = this.a.getLayout();
        if(v2 != null && v2.getLineCount() >= this.b && (v2.getLineCount() != this.b || v2.getEllipsisStart(this.b - 1) != 0)) {
            int v0_1 = v2.getLineEnd(this.b - 1);
            CharSequence v2_1 = this.a.getText();
            if(v0_1 <= 2) {
                v0_1 = v2_1.length();
            }
            SpannableStringBuilder v2_2 = new SpannableStringBuilder(v2_1.subSequence(0, v0_1 - 2));
            v2_2.append('…');
            this.a.setText(((CharSequence)v2_2));
            v0 = false;
        }

        return v0;
    }
}

